<template>
  <div class="not-found-page">
    <div class="not-found-container">
      <div class="error-content">
        <div class="error-animation">
          <div class="number">4</div>
          <div class="icon">🔍</div>
          <div class="number">4</div>
        </div>
        
        <h1 class="error-title">页面未找到</h1>
        <p class="error-message">抱歉，您访问的页面不存在或已被移除</p>
        
        <div class="error-actions">
          <button @click="goBack" class="btn-secondary">
            <i class="icon">⬅️</i>
            返回上一页
          </button>
          <button @click="goHome" class="btn-primary">
            <i class="icon">🏠</i>
            返回首页
          </button>
        </div>
        
        <div class="suggestions">
          <p class="suggestions-title">您可能在寻找：</p>
          <ul class="suggestions-list">
            <li><router-link to="/articles">我的文章</router-link></li>
            <li><router-link to="/profile">个人中心</router-link></li>
            <li><router-link to="/login">登录页面</router-link></li>
          </ul>
        </div>
      </div>
      
      <div class="floating-elements">
        <div class="element element-1">📄</div>
        <div class="element element-2">📝</div>
        <div class="element element-3">📁</div>
        <div class="element element-4">🔖</div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
import { getUserMenus } from '../router'
import { getFirstMenuPath } from '../utils/routerHelper'

const router = useRouter()

const goBack = () => {
  router.back()
}

const goHome = () => {
  // 获取用户菜单，跳转到第一个菜单页
  const menus = getUserMenus()
  if (menus && menus.length > 0) {
    const firstPath = getFirstMenuPath(menus)
    router.push(firstPath)
  } else {
    // 如果没有菜单，跳转到登录页
    router.push('/login')
  }
}
</script>

<style scoped>
.not-found-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.not-found-container {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 600px;
}

.error-content {
  background: white;
  border-radius: 20px;
  padding: 60px 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  animation: slideUp 0.5s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.error-animation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 30px;
}

.number {
  font-size: 120px;
  font-weight: 900;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: bounce 2s ease-in-out infinite;
}

.icon {
  font-size: 80px;
  font-style: normal;
  animation: rotate 3s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
}

@keyframes rotate {
  0%, 100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(180deg);
  }
}

.error-title {
  font-size: 32px;
  color: #2c3e50;
  margin-bottom: 15px;
  font-weight: 700;
}

.error-message {
  font-size: 16px;
  color: #7f8c8d;
  margin-bottom: 40px;
  line-height: 1.6;
}

.error-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.btn-primary,
.btn-secondary {
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: #f5f7fa;
  color: #555;
}

.btn-secondary:hover {
  background: #e8ecf1;
  transform: translateY(-2px);
}

.suggestions {
  padding-top: 30px;
  border-top: 1px solid #e0e0e0;
}

.suggestions-title {
  font-size: 14px;
  color: #7f8c8d;
  margin-bottom: 15px;
  font-weight: 600;
}

.suggestions-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.suggestions-list li a {
  color: #667eea;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.3s;
}

.suggestions-list li a:hover {
  color: #764ba2;
  text-decoration: underline;
}

/* 浮动元素 */
.floating-elements {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: hidden;
}

.element {
  position: absolute;
  font-size: 40px;
  opacity: 0.2;
  animation: float 15s ease-in-out infinite;
}

.element-1 {
  top: 10%;
  left: 10%;
  animation-delay: 0s;
}

.element-2 {
  top: 70%;
  left: 15%;
  animation-delay: 3s;
}

.element-3 {
  top: 20%;
  right: 15%;
  animation-delay: 6s;
}

.element-4 {
  bottom: 15%;
  right: 10%;
  animation-delay: 9s;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-30px) rotate(180deg);
  }
}

/* 响应式设计 */
@media (max-width: 480px) {
  .error-content {
    padding: 40px 30px;
  }

  .number {
    font-size: 80px;
  }

  .icon {
    font-size: 50px;
  }

  .error-title {
    font-size: 24px;
  }

  .error-message {
    font-size: 14px;
  }

  .error-actions {
    flex-direction: column;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    justify-content: center;
  }

  .suggestions-list {
    flex-direction: column;
    gap: 10px;
  }
}
</style>
